package com.example.eventdemo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Cary
 * @date 2022/3/24
 */
@RestController
public class TestController {
    @Autowired
    private ApplicationEventPublisher publisher;

    @RequestMapping("/sendEvent")
    public String sendEvent() {
        SysLogDTO log = new SysLogDTO();
        log.setId(1L);
        log.setContext("It is log...");
        publisher.publishEvent(new SysLogEvent(log));
        return "ok";
    }
}
